from time import sleep
import uiautomation
import pyautogui


class Jianchajianyan():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    jianyanjiancha = his.TabControl(AutomationId='tabZhenliao', ClassName='TabControl').TabItemControl(Name='检验检查',ClassName='TabItem')  # 检验检查
    # 检查检验
    jiancha_xiangmumumingcheng1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=1)
    jiancha_xiangmumumingcheng1_1 = jiancha_xiangmumumingcheng1.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')  # 项目名称输入框

    jiancha_xiangmumumingcheng2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=2)
    jiancha_xiangmumumingcheng2_1 = jiancha_xiangmumumingcheng2.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')  # 项目名称输入框

    jiancha_xiangmumumingcheng3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=3)
    jiancha_xiangmumumingcheng3_1 = jiancha_xiangmumumingcheng3.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')  # 项目名称输入框

    jiancha_xiangmumumingcheng4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=4)
    jiancha_xiangmumumingcheng4_1 = jiancha_xiangmumumingcheng4.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')  # 项目名称输入框

    jiancha_xiangmumumingcheng5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=5)
    jiancha_xiangmumumingcheng5_1 = jiancha_xiangmumumingcheng5.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')  # 项目名称输入框

#检查检验
    #点击检查检验
    def click_jianyanjiancha_btn(self):
        self.jianyanjiancha.Click()
        sleep(1)
#输入项目名称
    def choose_jyjc_xmmc1(self,xmmc1):
            self.jiancha_xiangmumumingcheng1.DoubleClick()
            self.jiancha_xiangmumumingcheng1_1.SendKeys(xmmc1)
            sleep(1)
            pyautogui.press('enter')

    def choose_jyjc_xmmc2(self,xmmc2):
            self.jiancha_xiangmumumingcheng2.DoubleClick()
            self.jiancha_xiangmumumingcheng2_1.SendKeys(xmmc2)
            pyautogui.press('enter')

    def choose_jyjc_xmmc3(self,xmmc3):
            self.jiancha_xiangmumumingcheng3.DoubleClick()
            self.jiancha_xiangmumumingcheng3_1.SendKeys(xmmc3)
            pyautogui.press('enter')

    def choose_jyjc_xmmc4(self,xmmc4):
            self.jiancha_xiangmumumingcheng4.DoubleClick()
            self.jiancha_xiangmumumingcheng4_1.SendKeys(xmmc4)
            pyautogui.press('enter')

    def choose_jyjc_xmmc5(self,xmmc5):
            self.jiancha_xiangmumumingcheng5.DoubleClick()
            self.jiancha_xiangmumumingcheng5_1.SendKeys(xmmc5)
            pyautogui.press('enter')

